package com.xiaohudie.aop;

import com.xiaohudie.annotation.LJL;
import com.xiaohudie.util.DynamicDataSource;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Author xiao hu die
 * @Date 2022/4/6 21:50
 * @Version 1.0
 */
@Component
@Aspect
public class DynamicDataSourceAspect {
/**前置或者环绕通知都是可行的*/
//@Order(-1)
@Before("within(com.xiaohudie.servier.Impi.*)  &&  @annotation(ljl)")
    public void before(JoinPoint point, LJL ljl){
    String name  =ljl.value();
    DynamicDataSource.name.set(name);
    System.out.println("数据源是:"+name);
}
}
